var app = angular.module('classDetailApp',[]);
app.controller('classDetailController',function($scope,$http){

    $scope.cid = $('#getCid').val();
    $http({
        method: 'POST',
        url: 'timetable/findClassByCid',
        data: $.param({"cid":$scope.cid}),
        headers: { 'Content-Type': 'application/x-www-form-urlencoded'}
    }).then(function successCallback(response) {
        console.log(response);
        $scope.class = response.data.class;
        console.log($scope.class);
        $("#ex-status").attr("value", $scope.class.applicationStatus);
    }, function errorCallback(response) {
        console.log("获取课程详情失败！");
    });

    /*删除课程操作*/
    $scope.deleteClass = function () {
        if(confirm("确定删除该课程信息吗？")){
            $http({
                method: 'POST',
                url: 'timetable/deleteClass',
                data: $.param({"cid":$scope.cid}),
                headers: { 'Content-Type': 'application/x-www-form-urlencoded'}
            }).then(function successCallback(response) {
                console.log(response);
                $scope.isSuccess = response.data.isSuccess;
                if($scope.isSuccess){
                    alert("删除成功");
                    window.location.href = "/classmsg.do";
                }else
                    alert("删除失败");
            }, function errorCallback(response) {
                console.log("获取失败！");
            });
        }
    };

    $scope.backToClassList = function () {
        window.location.href = "/classmsg.do";
    };

});